package com.gimi.cloud.bbp.dao.dao.mall;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.gimi.cloud.bbp.dao.myMapper.MyMapper;
import com.gimi.cloud.bbp.dto.mall.MallMessageDTO;
import com.gimi.cloud.bbp.entity.mall.MallMessage;

@Mapper
public interface MallMessageDao extends MyMapper<MallMessage>{
	
	/**
	 * 获取消息列表
	 * @param userId
	 * @return
	 */
	@Select("select * from mall_message where me_receive_user = #{userId} and is_delete = 0 and me_del_type = 0")
	List<MallMessageDTO> getMessageListByReceiveUser(Integer userId);
	
	/**
	 * 获取消息详情
	 * @param meId
	 * @return
	 */
	@Select("select * from mall_message where me_id = #{meId} and is_delete = 0 and me_del_type = 0") 
	MallMessage getMessageByMeId(Integer meId);
	
	/**
	 * 获取未读消息条数
	 * @param meId
	 * @return
	 */
	@Select("select count(*) from mall_message where me_receive_user = #{userId} and me_status = 0 and is_delete = 0") 
	Long getMessageByUserIdAndStatus(Integer userId);
	
 
}
